package priv.conceit.sc.hoxton.auth.core;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.DAYS;

/**
 * sc-hoxton
 *
 * @author Conceit
 * @since 1.0.0, 2020/11/3
 */
@Component
@RefreshScope
@ConfigurationProperties(prefix = AuthProperties.PREFIX)
@Data
public class AuthProperties {

	public static final String PREFIX="auth";

	/**
	 * token
	 */
	private Token token;

	/**
	 * 组织架构
	 */
	private Org org;


	/**
	 * 权限
	 */
	private Authority authority;

	/**
	 * 用户
	 */
	private User user;

	/**
	 * 承包商
	 */
	private Contractor contractor;

	/**
	 * 承包商相关
	 */
	@Data
	public static class Contractor{
		private Boolean cache=true;
		private TimeUnit expiresTimeUnit=DAYS;
		private Long expiresTime= 1L;
	}

	/**
	 * 权限相关
	 */
	@Data
	public static class Authority{
		private Boolean cache=true;
		private TimeUnit expiresTimeUnit=DAYS;
		private Long expiresTime= 1L;
	}

	/**
	 * 用户
	 */
	@Data
	public static class User {


		private Password password;


		/**
		 * 密码
		 */
		@Data
		public static class Password{

			/**
			 * 密钥
			 */
			private String secretKey="default";

			/**
			 * 盐
			 */
			private String salt="salt";

			/**
			 * 密码的最短最长位数
			 */
			private Integer minLength=8;
			private Integer maxLength=36;
			/**
			 * 默认密码
			 */
			private String defaults="qq809411396";
		}
	}

	/**
	 * 组织架构
	 */
	@Data
	public static class Org{
		private Boolean cache=true;
		private TimeUnit expiresTimeUnit=DAYS;
		private Long expiresTime= 1L;
	}



	/**
	 * token 配置
	 */
	@Data
	public static class Token{

		/**
		 * 过期时间单位
		 */
		private TimeUnit expiresTimeUnit=DAYS;

		/**
		 * 过期时间-7天
		 */
		private Long expiresTime= 7L;


		/**
		 * 密钥
		 */
		private String secretKey="default";

		/**
		 * 盐
		 */
		private String salt="salt";

		/**
		 * 缓存上 key的分隔符
		 */
		private String separator=",";
	}






}
